#include "OpReverse.h"
#include "Qt3DPicker.h"
#include "INode.h"
#include "Registry.h"
#include "ActorTable.h"
#include "Ent.h"

class OpReversePrivate
{
public:
	std::set<std::shared_ptr<Ent3DFace>> m_faces;
};

OpReverse::OpReverse(const std::set<std::shared_ptr<Ent3DFace>>& faces, QUndoCommand *parent)
	: Op(parent)
	,d_ptr(new OpReversePrivate)
{
	d_ptr->m_faces = faces;
}

OpReverse::~OpReverse()
{
	delete d_ptr;
}

#include "QtOSGWidget.h"
void OpReverse::redo()
{
	Registry &reg = Registry::instance();
	auto widget3D = reg.get<QtOSGWidget>(widget3DID);
	widget3D->pauseRenderThread();

	for (auto face : d_ptr->m_faces)
	{
		face->reverse();
	}
	widget3D->resumeRenderThread();
}

void OpReverse::undo()
{
	redo();
}
